package com.zc.study.spring.第一章.spring1_2_1;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 基于文件,读取hello world 所需的字符串
 */
public class FileHelloStr {
    private  final Logger logger = LoggerFactory.getLogger(this.getClass());
    private String propFilename;

    public FileHelloStr(String propFilename) {
        this.propFilename = propFilename;
    }

    public String getContant(){
        String helloworld = "";
        //new properties包导入对应的文件
        try {
            Properties properties = new Properties();
            InputStream is = this.getClass().getClassLoader().getResourceAsStream(propFilename);
            properties.load(is);
            is.close();
            helloworld = properties.getProperty("helloworld");
        } catch (IOException e) {
            logger.debug("io转换异常:{}",e);
        }
        return helloworld;
    }

}
